package org.chen.tomcat;

import java.net.Socket;
import java.util.Map;

/**
 * 请求对象
 *
 * @author Chen
 * @since 2023/6/9 15:35
 */
public class Request extends AbstractHttpServletRequest {

    private final String method;

    private final String url;

    private final String protocol;

    private final Socket socket;

    private final Map<String, String[]> parameterMap;

    public Request(String method, String url, Map<String, String[]> parameterMap, String protocol, Socket socket) {
        this.method = method;
        this.url = url;
        this.parameterMap = parameterMap;
        this.protocol = protocol;
        this.socket = socket;
    }

    @Override
    public String getMethod() {
        return method;
    }

    @Override
    public StringBuffer getRequestURL() {
        return new StringBuffer(url);
    }

    @Override
    public String getRequestURI() {
        return url;
    }

    @Override
    public Map<String, String[]> getParameterMap() {
        return parameterMap;
    }

    @Override
    public String getProtocol() {
        return protocol;
    }

    public Socket getSocket() {
        return socket;
    }
}
